<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
    <script src="https://cdn.jsdelivr.net/npm/vue@2.6.10/dist/vue.js"></script>
  </head>
  <body>
    <div id="app">
      <!-- 
        .prevent修饰符：阻止当前事件的默认行为
        .once修饰符：当前事件只能触发一次
     -->

      <button @contextmenu.prevent.once="contextMenu">
        右键点一下,看有没有菜单
      </button>

      <hr />
      <!-- 
        .self修饰符：控制只有当前绑定事件的元素上发生事件，才能触发事件
     -->
      <div @click.self="outerClick">
        outer
        <div>
          inner
          <div>content</div>
        </div>
      </div>

      <!-- 
        按键别名修饰符
            .enter(配合键盘事件使用):当输入回车的时候执行回调函数
     -->
      <input type="text" @keyup.enter="publish" />
    </div>
    <script>
        Vue.config.productionTip = false;
        const vm = new Vue({
            el:"#app",
            data() {
                return {

                };
            },
            methods: {
                contextMenu() {
                    console.log("右键触发");
                },
                outerClick() {
                    console.log("outer");
                },
                innerClick() {
                    console.log("inner");
                },
                contentClick() {
                    console.log("content");
                },
                publish() {
                    console.log("publish");
                },
            },
        });

    </script>
  </body>
</html>
